#include"khaibao.h"
void Nhap(student_t *st,int n)
{
	int k;
	for(int i=0;i<n;i++)
	{
		cout<<"name: ";
		cin.ignore();
		gets((st+i)->name);

		cout<<"age: ";
		cin>>(st+i)->age;
		do{
			cout<<"input grades: ";
			cin>>k;
			if(k==0)
				break;
			(st+i)->grades.push_back(k);
		}while(1);
	}
}
void Xuat(student_t *st,int n)
{
	for(size_t i=0;i<n;i++)
	{
		cout<<"\nname: "<<(st+i)->name;
		cout<<"\nage: "<<(st+i)->age;
		cout<<"\ngrades: ";
		for(size_t j=0;j<(st+i)->grades.size();j++)
		{
			cout<<(st+i)->grades[j]<<"\t";
		}
	}
}
void TimKiem(student_t *st,int n,int age)
{
	for(size_t i=0;i<n;i++)
	{
		if((st+i)->age==age)
		{
			cout<<"\nname: "<<(st+i)->name;
			cout<<"\nage: "<<(st+i)->age;
			cout<<"\ngrades: ";
			for(size_t j=0;j<(st+i)->grades.size();j++)
			{
				cout<<(st+i)->grades[j]<<"\t";
			}
		}
	}
}
void HoanVi(student_t &st,student_t &sv)
{
	student_t temp;
	temp=st;
	st=sv;
	sv=temp;
}
void SapXep(student_t *st,int n)
{
	for(size_t i=0;i<n-1;i++)
	{
		for(size_t j=i+1;j<n;j++)
		{
			if((st+i)->age>(st+j)->age)
			{
				HoanVi(*(st+i),*(st+j));
			}
		}
	}
}
